home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / magazi~1 / 371 / bitblit.pas next >
Encoding:
Pascal/Delphi Source File  |  1989-03-10  |  3.6 KB  |  121 lines

  1. {$M+}
  2. {$E+}
  3. {******************************************************************}
  4. {*  This program is to be linked with PICPUZZL.PAS.  These are    *}
  5. {*  the routines needed to do the raster operations.              *}
  6. {******************************************************************}
  7.  
  8. program addr_stuff;
  9.  
  10. const
  11.   low_resolution = 1 ;
  12.   medium_resolution = 2 ;
  13.   high_resolution = 3 ;
  14.  
  15. type
  16.    {* These are echos of types in PICPUZZL.PAS *}
  17.    scrn_memory = array[1..16000] of integer;
  18.    mfdb_fields = (addr1,addr2,wid_pix,ht_pix,wid_wds,flag,num_planes,r1,r2,r3);
  19.    mfdb = array[mfdb_fields] of integer;
  20.  
  21. PROCEDURE init_form(var form : MFDB; addr : long_integer; res: integer);
  22.         { initializes a form to point to a chunk of memory off screen }
  23.         { note that the caller passes a 32K chunk of memory as what it
  24.           thinks is a var parameter, thus passing its address }
  25. var
  26.    hi_byte,lo_byte : integer;
  27.  
  28. begin
  29.         { convert the address to integers }
  30.    lo_byte := int(addr & $0000ffff);
  31.    hi_byte := int( ShR(addr,16) & $0000ffff);
  32.         { and initialize all fields of the MFDB }
  33.    form[addr1] := hi_byte;
  34.    form[addr2] := lo_byte;
  35.    IF res = high_resolution THEN
  36.      BEGIN
  37.        form[wid_pix] := 640 ;
  38.        form[ht_pix] := 400 ;
  39.        form[wid_wds] := 40 ;
  40.        form[num_planes] := 1 ;
  41.      END
  42.    ELSE
  43.      IF res = medium_resolution THEN
  44.        BEGIN
  45.          form[wid_pix] := 640 ;
  46.          form[ht_pix] := 200 ;
  47.          form[wid_wds] := 40 ;
  48.          form[num_planes] := 2 ;
  49.        END
  50.      ELSE
  51.        BEGIN
  52.          form[wid_pix] := 320 ;
  53.          form[ht_pix] := 200 ;
  54.          form[wid_wds] := 20 ;
  55.          form[num_planes] := 4 ;
  56.        END ;
  57.    form[flag] := 0;             { device dependent }
  58. end;
  59.  
  60. PROCEDURE copy_rect(src,dst : long_integer;
  61.                     from_x,from_y,to_x,to_y,width,height : integer);
  62.         { heres where we actually copy a rectangle from one loc. to another }
  63.         { using gem raster copy function }
  64.  
  65.     TYPE
  66.       Ctrl_Parms      = ARRAY [ 0..11 ] OF integer ;
  67.       Int_In_Parms    = ARRAY [ 0..15 ] OF integer ;
  68.       Int_Out_Parms   = ARRAY [ 0..45 ] OF integer ;
  69.       Pts_In_Parms    = ARRAY [ 0..11 ] OF integer ;
  70.       Pts_Out_Parms   = ARRAY [ 0..11 ] OF integer ;
  71.  
  72.     VAR
  73.       control : Ctrl_Parms ;
  74.       int_in  : Int_In_Parms ;
  75.       int_out : Int_Out_Parms ;
  76.       pts_in  : Pts_In_Parms ;
  77.       pts_out : Pts_Out_Parms ;
  78.  
  79.       hi_byte,lo_byte : integer;
  80.  
  81.  
  82.     PROCEDURE VDI_Call( cmd, sub_cmd : integer ; nints, npts : integer ;
  83.                 VAR ctrl : Ctrl_Parms ;
  84.                 VAR int_in : Int_In_Parms ; VAR int_out : Int_Out_Parms ;
  85.                 VAR pts_in : Pts_In_Parms ; VAR pts_out : Pts_Out_Parms ;
  86.                 translate : boolean ) ;
  87.       EXTERNAL ;
  88.  
  89.  
  90. begin
  91.         { put source MFDB address in control array }
  92.    lo_byte := int(src & $0000ffff);
  93.    hi_byte := int( ShR(src,16) & $0000ffff);
  94.    control[7] := hi_byte; control[8] := lo_byte;
  95.  
  96.        { and same for destination MFDB }
  97.    lo_byte := int(dst & $0000ffff);
  98.    hi_byte := int( ShR(dst,16) & $0000ffff);
  99.    control[9] := hi_byte; control[10] := lo_byte;
  100.  
  101.    int_in[0] := 3;      { replace mode }
  102.  
  103.         { set the points for src and dest }
  104.    pts_in[0] := from_x; pts_in[1] := from_y;
  105.    pts_in[2] := from_x + width - 1;
  106.    pts_in[3] := from_y + height - 1;
  107.  
  108.    pts_in[4] := to_x; pts_in[5] := to_y;
  109.    pts_in[6] := to_x + width - 1;
  110.    pts_in[7] := to_y + height - 1;
  111.  
  112.         { do the copy }
  113.    VDI_Call(109,0,1,8,control,int_in,int_out,pts_in,pts_out,false);
  114.  
  115. end;
  116.  
  117.         { just a module, no main program }
  118. begin
  119. end.
  120.  
  121.